﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace Oblivion.Core
{
    /// <summary>
    /// PacketType Names
    /// </summary>
    public enum PacketTypes
    {
        Login,
        Move,
        WorldState,
        Chat,
        LoginDoesNotExist,
        PasswordMismatch,
        Online,
        Version,
        LoginSuccessful,
        CharacterLocation,
        Characters,
        CharactersInfo,
        CreateCharacter,
        CharacterNameTaken
    }

    public enum ChatTypes
    {
        ServerMessage,
        Private,
        Area
    }
    /// <summary>
    /// Child Socket State for Client, Connected, Disconnecting
    /// </summary>
    public enum ChildSocketState
    {
        Connected,
        Disconnecting
    }
    /// <summary>
    /// Socket State for Server, Closed, Connecting, Connected, Disconnecting
    /// </summary>
    public enum SocketState
    {
        Closed,
        Connecting,
        Connected,
        Disconnecting
    }

    public class ReadText
    {
        public string Version;
        public string Txt;
        public void ReadT(string Text)
        {
            StreamReader sr = File.OpenText(Text);
            string input = null;
            if (Text == "Version.ID")
            {
                while ((input = sr.ReadLine()) != null)
                {
                    Version = input;
                    return;
                }
            }
            else
            {
                while ((input = sr.ReadLine()) != null)
                {
                    Txt = input;
                    return;
                }
            }
            sr.Close();
        }
    }

    public static class ConvertEnums
    {
        public static int EnumToInt(System.Enum whatEnum)
        {
            return int.Parse(whatEnum.ToString("d"));
        }

        public static T ToEnum<T>(this string enumString)
        {
            return (T)Enum.Parse(typeof(T), enumString);
        }
    }

    public class Information
    {
    }
}
